package tw.com.msig.b2c.car.setting.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import tw.com.msig.b2c.car.setting.dao.ZipcodeDao;
import tw.com.msig.b2c.car.setting.service.ZipcodeService;
import tw.com.msig.b2c.car.setting.vo.ZipcodeVo;

public class ZipcodeServiceImpl implements ZipcodeService {
	
	private Logger log = LoggerFactory.getLogger(this.getClass());
	
	private ZipcodeDao zipcodeDao;

	public ZipcodeDao getZipcodeDao() {
		return zipcodeDao;
	}

	public void setZipcodeDao(ZipcodeDao zipcodeDao) {
		this.zipcodeDao = zipcodeDao;
	}
	
	@Override
	public List<ZipcodeVo> getAll() {
		return zipcodeDao.findAll();
	}

	@Override
	public ZipcodeVo getById(long id) {		
		return zipcodeDao.findById(id);
	}

	@Override
	public void insert(ZipcodeVo zipcodeVo) {
		zipcodeDao.insert(zipcodeVo);		
	}

	@Override
	public void update(ZipcodeVo zipcodeVo) {
		ZipcodeVo dbVo = zipcodeDao.findById(zipcodeVo.getId());
		dbVo.setName(zipcodeVo.getName());
		dbVo.setZipCode(zipcodeVo.getZipCode());
		zipcodeDao.update(dbVo);
	}

	@Override
	public void delete(ZipcodeVo zipcodeVo) {
		zipcodeDao.delete(zipcodeVo);
	}

}
